package com.usf.jprovider.schema.provider.random.date;

import java.util.Calendar;

import org.apache.commons.lang3.time.DateUtils;

import com.usf.jprovider.object.JObjectNode;
import com.usf.jprovider.object.env.Environment;
import com.usf.jprovider.object.type.JDate;
import com.usf.jprovider.object.type.JType;

public final class ToDay extends AbstractDateRandomProvider{
	
	public ToDay() {
		super();
	}

	@Override
	public JDate create(Environment env, JObjectNode node) {
		return new JDate(Calendar.getInstance().getTime(), type.getFormat());
	}	
	@Override
	public boolean checkValue(Environment env, JObjectNode node, JType<?> value) {
		JDate date = (JDate) value;
		return DateUtils.isSameDay(Calendar.getInstance().getTime(), date.getValue());
	}
}
